# while
# 猜大小游戏
# 死循环
# while True:
#     true_number = 30
#     number = input('请输入一个数字：')
#     number = int(number)
#     if number > true_number:
#         print('猜大了')
#     elif number < true_number:
#         print('猜小了')
#     else:
#         print('猜对了')
#         # 终止跳出循环
#         break

# 从1累加到100
n = 1
amount = 0

while n <= 100:
    amount = amount + n
    n = n + 1

print(amount)


# for item in 可迭代对象。  ‘abc'  [1, 2, 3]  1,2,3,4...
amount = 0
for n in range(1, 101):
    amount = amount + n
    # print(n)
print(amount)

for i in [1,2,3]:
    print(i)

for i in 'abc':
    print(i)


# 练习：
# *
# **
# ***
# ****
for x in range(1, 5):
    # print('x:', x)
    for y in range(1, x+1):
        # print('y:', y)
        print('*', end='')
    print('')

# 其它，99乘法表、秋水花仙数、等比数列。

# 跳出循环。
# break终止 跳出所有循环。 continue 跳过'本次'循环。
for n in range(10):
    print(n)
    if n == 5:
        break

for n in range(10):
    if n == 5:
        continue
    print(n)

